package com.example.werthwedemo0309.fragment;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.werthwedemo0309.R;

import java.util.List;

public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactHolder> {
     private List<ContactModel> data;

    public void setData(List<ContactModel> data) {
        this.data = data;
    }

    private Context context;

    public ContactAdapter(Context context) {
        this.context = context;
    }

    @Override
    public ContactHolder onCreateViewHolder(@NonNull  ViewGroup parent, int viewType) {
         return new ContactHolder(LayoutInflater.from(context).inflate(R.layout.item_list,null));
    }

    @Override
    public void onBindViewHolder(@NonNull  ContactAdapter.ContactHolder holder, int position) {
        holder.text_day.setText(data.get(position).getListDay());
        holder.text_info.setText(data.get(position).getListInfo());
        holder.text_faut.setText(data.get(position).getListfaut());

    }

    @Override
    public int getItemCount() {
        return null!=data?data.size():0;
    }

    class ContactHolder extends RecyclerView.ViewHolder{
        TextView text_day;
        TextView text_info;
        TextView text_faut;

        public ContactHolder(@NonNull  View itemView) {
            super(itemView);
            text_day=itemView.findViewById(R.id.text_day);
            text_info=itemView.findViewById(R.id.text_info);
            text_faut=itemView.findViewById(R.id.text_faut);
        }
    }
}
